package example4;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;

public class TestByteArrayInputOutputStream {
    
    public static void main(String[] args) throws Exception {
        FileInputStream inputStream = new FileInputStream("1.txt");
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        
        byte[] bytes = new byte[10];
        
        while (true) {
            int num = inputStream.read(bytes);
            if (num == -1) {
                break;
            }
            outputStream.write(bytes, 0, num);
        }

        byte[] byteArray = outputStream.toByteArray();
        System.out.println(byteArray.length);
    }
}
